package numbers;

public class SuperstitionRespectingNumberGenerator implements INumberGenerator {

	private int number = 0;
	
	private void throwNumberToDangerousException(int value) {
		throw new RuntimeException("I can't use the number " + value
				+ ", because it's too dangerous!");
	}

	public int nextNumber() {
		if (Integer.toString(number).endsWith("13")) number++;
		return number++;
	}

	public void setNextNumber(int value) {
		if (value == 13) throwNumberToDangerousException(13);
		number = value;
	}

}
